<template>
  <div class="viewDialog">
    <el-dialog
      title="审核"
      :visible.sync="dialogVisible"
      width="40%">
      <div>
        <el-form ref="form" :model="viewForm" label-width="80px" size="small">
          <el-form-item label="审核意见" prop="desc">
            <el-input type="textarea" :rows="2" class="viewInput" v-model="viewForm.desc"></el-input>
          </el-form-item>
          <el-form-item label="状态" prop="viewRadio">
            <el-radio v-model="viewForm.viewRadio" border :label="1">审核通过</el-radio>
            <el-radio v-model="viewForm.viewRadio" border :label="2">审核不通过</el-radio>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="dialogVisible = false">取 消</el-button>
        <el-button size="small" type="primary" @click="submitViewStatus">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { viewReportCard } from '@/api/hospital/reportreview.js'
export default {
  data() {
    return {
      dialogVisible: false,
      viewForm: {
        id: '',
        viewRadio: 1,
        desc: ''
      }
    }
  },
  methods: {
    // 初始化
    init(id, flag) {
      this.viewForm.id = id
      this.dialogVisible = flag
    },
    // 提交审核状态
    submitViewStatus() {
      const data = {
        id: this.viewForm.id,
        auditStatus: this.viewForm.viewRadio
      }
      viewReportCard(data).then((res) => {
        if (res.code === 200) {
          this.dialogVisible = false
          this.$emit('handleReportView')
          // 清空数据
          this.$refs.form.resetFields()
          this.viewForm.id = ''
        }
      })
    },
  }
}
</script>

<style scoped>
  .viewInput {
    width: 100% !important;
  }
</style>
